@@include("./common/_menu.js")
@@include("./common/_popWindow.js")
function item_masonry(){ 
	$('.favorite-box img').load(function(){ 
		$('.infinite-scroll').masonry({ 
			itemSelector: '.item',
			columnWidth:1180,
			gutterWidth:0								
		});		
	});
		
	$('.infinite-scroll').masonry({ 
		itemSelector: '.item',
		columnWidth:1180,
		gutterWidth:0								
	});	
}
item_masonry();
$(".infinite-scroll").infinitescroll({
	navSelector: ".recommend-more",
	nextSelector: ".recommend-more a",
	itemSelector: ".item",
	requestUrl: "./lib/recommend.json?type=home&categor_id=1&page=",
	
	loading:{
		img: "images/masonry_loading_1.gif",
		msgText: ' ',
		finishedMsg: '',
		render: function(resData,opts){
			var data = "";
			try{
                var temp = JSON.parse(resData);
                if(temp.code == 200) {
                    if(opts.state.currPage >= temp.data.last_page){
                        opts.state.isFinished = true;
                    }
                    console.log(temp.data.data);
                    $.each(temp.data.data,function(i,item){
                        data += '<div class="img-text item"><div class="img-text-left"><a href="'+item.href1+'"><span class="img-show"><img src="'+item.cover+'"></span></a></div><div class="img-text-right"><a href="'+item.href2+'" class="descrption">'+item.name+'</a><div class="tips"><a href="'+item.href5+'">#'+item.category_name+'</a>';
                            if(item.brand_list && item.brand_list.length>0){
                                $.each(item.brand_list,function(j,it){
                                    data += '<a data-id='+it.brand_id+' href="'+item.href3+'">#'+it.brand_name+'</a>';
                                })
                            }
                        data += '</div><div class="introduce">'+item.intro+'</div>';
                        data += '</div></div>';  
                    })
                }
            }catch(e){}
            return data;
		},
		finished: function(opts){
			if(opts.state.isFinished){ //结束事件
				$(".recommend-more").remove();
				//$("#infscr-loading").hide();
				$(window).unbind('.infscr');
			}
		}	
	},errorCallback:function(res){ 
		console.log(res);
	}
	
},function(newElements){
	var $newElems = $(newElements);
	$('.infinite-scroll').masonry('appended', $newElems, false);
	$newElems.fadeIn();
	item_masonry();
	return;
});
var swiper = new Swiper('.swiper-container', {
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
	loop : true,
	autoplay:true,
  });